Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Obtaining Information About Available Sound Features

You can use the Gestalt function to obtain information about a number of hardware- and software-related sound features. For instance, you can use Gestalt to determine whether a machine can produce stereophonic sounds and whether it can mix both left and right channels of sound on the internal speaker. Many applications don't need to call Gestalt to get this kind of information if they rely on the Sound Manager's ability to produce reasonable sounding output on whatever audio hardware is available. Other applications, however, do need to use Gestalt to get this information if they depend on specific hardware or software features that are not available on all Macintosh computers.

To get sound-related information from Gestalt , pass it the gestaltSoundAttr selector.

CONST
    gestaltSoundAttr                = 'snd ';       {sound attributes}

If Gestalt returns successfully, it passes back to your application a 32-bit value that represents a bit pattern. The following constants define the bits currently set or cleared by Gestalt :

CONST
    gestaltStereoCapability             = 0;        {built-in hw can play stereo sounds}
    gestaltStereoMixing                 = 1;        {built-in hw mixes stereo to mono}
    gestaltSoundIOMgrPresent            = 3;        {sound input routines available}
    gestaltBuiltInSoundInput            = 4;        {built-in input hw available}
    gestaltHasSoundInputDevice          = 5;        {sound input device available}
    gestaltPlayAndRecord                = 6;        {built-in hw can play while recording}
    gestalt16BitSoundIO                 = 7;        {built-in hw can handle 16-bit data}
    gestaltStereoInput                  = 8;        {built-in hw can record stereo sounds}
    gestaltLineLevelInput               = 9;        {built-in input hw needs line level}
    gestaltSndPlayDoubleBuffer          = 10;       {play from disk routines available}
    gestaltMultiChannels                = 11;       {multiple channels of sound supported}
    gestalt16BitAudioSupport            = 12;       {16-bit audio data supported}

If the bit gestaltStereoCapability is TRUE , the built-in hardware can play stereo sounds. The bit gestaltStereoMixing indicates that the sound hardware of the machine mixes both left and right channels of stereo sound into a single audio signal for the internal speaker. Listing 1-19 demonstrates the use of the Gestalt function to determine if a machine can play stereo sounds.

Listing 19 Determining if stereo capability is available

FUNCTION MyHasStereo: Boolean;
VAR
    myFeature:          LongInt;
    myErr:              OSErr;
BEGIN
    myErr := Gestalt(gestaltSoundAttr, myFeature);
    IF myErr = noErr THEN               {test stereo capability bit}
        MyHasStereo := BTst(myFeature, gestaltStereoCapability)
    ELSE
        MyHasStereo := FALSE;           {no sound features available}
END;

As shown in the chapter "Introduction to Sound on the Macintosh," you can determine whether your application can record by testing the gestaltHasSoundInputDevice bit. To determine whether a built-in sound input device is available, you can test the gestaltBuiltInSoundInput bit. The gestaltSoundIOMgrPresent bit indicates whether the sound input routines are available. Because the gestaltHasSoundInputDevice bit is not set if the routines are not available, only sound input device drivers should need to use the gestaltSoundIOMgrPresent bit.

For a complete description of the response bits set by Gestalt , see "Gestalt Selector and Response Bits" .


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |